package com.sailfish.springbootdemo.dao.db1;

import com.sailfish.springbootdemo.common.DB1TableName;
import com.sailfish.springbootdemo.pojo.db1.Bis;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;

import java.util.List;

public interface BisDao {

    /**
     * 根绝大类查询
     *
     * @param bisBigId
     * @return
     */
    @Results(id = "bisResultMap", value = {
            @Result(column = "bis_id", property = "bisId", jdbcType = JdbcType.INTEGER),
            @Result(column = "bis_key", property = "bisKey", jdbcType = JdbcType.VARCHAR),
            @Result(column = "bis_big_id", property = "bisBigId", jdbcType = JdbcType.INTEGER),
            @Result(column = "bis_value", property = "bisValue", jdbcType = JdbcType.VARCHAR),
            @Result(column = "bis_type", property = "bisType", jdbcType = JdbcType.VARCHAR),
            @Result(column = "create_time", property = "createTime", jdbcType = JdbcType.DATETIMEOFFSET),
            @Result(column = "update_time", property = "updateTime", jdbcType = JdbcType.DATETIMEOFFSET),
            @Result(column = "sort", property = "sort", jdbcType = JdbcType.INTEGER),
    })
    @Select("select * from " + DB1TableName.BIS + " where bis_big_id = #{bisBigId} order by sort")
    List<Bis> getAllBisByBigId(@Param("bisBigId") Integer bisBigId);

    /**
     * 根据key查询
     *
     * @param bisKey
     * @return
     */
    @Select("select * from " + DB1TableName.BIS + " where bis_key = #{bisKey}")
    @ResultMap(value = "bisResultMap")
    Bis getBisByKey(@Param("bisKey") String bisKey);
}
